/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * $Id: notification.hpp,v 1.2 2009-05-13 07:18:19 amaula Exp $
 *
 * \file
 * \brief Definition for common datatype 'TNotification'
 * \author Antti Maula <antti.maula@tkk.fi>
 */
#ifndef _MACI_COMMON_NOTIFICATION_HPP_
#define _MACI_COMMON_NOTIFICATION_HPP_
#include <inttypes.h>

namespace MaCI {
  namespace Common {
    
    /** Machine handleable notification codes.
     */
    enum ENotificationCode {
      KNotificationCodeNone         = 0, ///< No code.
      KNotificationCodeFatalError   = 1, ///< Fatal error
      KNotificationCodeWarning      = 2, ///< Warning
      KNotificationCodeNotice       = 3, ///< Notice (less than warning)
      KNotificationCodeMessage      = 4, ///< Just a message.
      KNotificationCodeDebug        = 5  ///< Debug information.
    };
    
    
    /** Notification.
     *
     * This structure contains 'Notification' data element
     * descriptions. The message field has no lenght specifier, it
     * must be calculated from the real container size. For example;
     * BinBag elements carry the size of the element. So the length of
     * 'message' field is 'total size - sizeof(TNotification)'.
     */
    struct TNotification
    { 
      TNotification()
        : notification_code(KNotificationCodeNone),
          level(0),
          reserved(0),
          notification_value(0),
          message() {}
      
      uint16_t notification_code;  ///< Notification code, see ENotificationCode.
      uint8_t level;               ///< Level of importance. 0 == critical, greater values less critical
      uint8_t reserved;            ///< No use yet. (Reserved)
      uint32_t notification_value; ///< Application specific value for notification.
      char message[];              ///< Freeform message (size is 'total - sizeof(TNotification)')
    };
  }
}
#endif //_MACI_COMMON_NOTIFICATION_HPP_
